﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ZDSoft.TES.Entity.SystemEntity;


namespace ZDSoft.TES.Web.Helpers
{
    public class AppHelper
    {
        public static User LoginedUser
        {
            get
            {
                return HttpContext.Current.Session["LoginedUser"] as User;
            }
            set
            {
                HttpContext.Current.Session["LoginedUser"] = value;
            }
        }

        public static IList<SystemFunction> Privileges
        {
            get
            {
                IList<SystemFunction> privileges = null;
                if (LoginedUser == null)
                {
                    return privileges;
                }
                privileges = new List<SystemFunction>();
                foreach (Role role in LoginedUser.Roles)
                {
                    foreach (SystemFunction function in role.SystemFunctions)
                    {
                        if (!privileges.Contains(function))
                        {
                            privileges.Add(function);
                        }
                    }
                }
                return privileges;
            }
        }

        public static int PageSize = 10;
    }
}